/**
 * Copyright (c) 2010-2020 Contributors to the openHAB project
 *
 * See the NOTICE file(s) distributed with this work for additional
 * information.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package org.openhab.core.auth;

import java.util.Date;

/**
 * An API token represents long-term credentials generated by an user, giving the bearer access to the API on behalf of
 * this user for a certain scope.
 *
 * @author Yannick Schaus - initial contribution
 *
 */
public class UserApiToken {
    String name;
    String apiToken;
    Date createdTime;
    String scope;

    /**
     * Constructs an API token.
     *
     * @param name the name of the token, for identification purposes
     * @param apiToken the token
     * @param scope the scope this token is valid for
     */
    public UserApiToken(String name, String apiToken, String scope) {
        super();
        this.name = name;
        this.apiToken = apiToken;
        this.createdTime = new Date();
        this.scope = scope;
    }

    /**
     * Gets the name identifying the token
     *
     * @return the API token
     */
    public String getName() {
        return name;
    }

    /**
     * Gets the API token which can be passed in requests as a "Bearer" token in the Authorization HTTP header.
     *
     * @return the API token
     */
    public String getApiToken() {
        return apiToken;
    }

    /**
     * Gets the time when this token was created.
     *
     * @return the date of creation
     */
    public Date getCreatedTime() {
        return createdTime;
    }

    /**
     * Gets the scope this token is valid for.
     *
     * @return the scope
     */
    public String getScope() {
        return scope;
    }
}
